package org.ntu.csn.doraemon.canvas;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import org.ntu.csn.doraemon.tool.Constant;


public class DiffForm implements CommandListener {	

	private List diff;
	
	private StartMenu sm;
	
	public DiffForm(StartMenu sm) {
		this.sm = sm;
		addDifficulty();
	}

	public void addDifficulty() {
		String[] stringArray = { "Easy","Moderate","Hard" };
        diff = new List("Difficulty", Choice.EXCLUSIVE, stringArray, null);
        diff.addCommand(Listener.back);
        diff.setCommandListener(this);
        diff.addCommand(Listener.ok);
        diff.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if ( c == Listener.back ) {
			Display.getDisplay(sm).setCurrent(StartMenu.mainMenu);
        } else if ( c == Listener.ok) {
       	 //load the game canvas
        	int diffnum = diff.getSelectedIndex();
        	Main mg = new Main(this.sm);
        	if(diffnum == 0) {
        		System.out.println("----------------easy");	
            	mg.start(Constant.MAX_Dorayakis_EASY, Constant.MAX_Bombs_EASY, Constant.MAX_Bomb2s_EASY, 
            			Constant.MAX_FairyWaters_EASY, Constant.MAX_Enhancers_EASY, 
            			Constant.MAX_Poisons_EASY, Constant.MAX_Lifes_EASY);
        	}
        	if(diffnum == 1) {
            	mg.start(Constant.MAX_Dorayakis_MODERATE, Constant.MAX_Bombs_MODERATE, Constant.MAX_Bomb2s_MODERATE, 
            			Constant.MAX_FairyWaters_MODERATE, Constant.MAX_Enhancers_MODERATE, 
            			Constant.MAX_Poisons_MODERATE, Constant.MAX_Lifes_MODERATE);
        	}
        	if(diffnum == 2) {
        		System.out.println("----------------hard");        		
            	mg.start(Constant.MAX_Dorayakis_HARD, Constant.MAX_Bombs_HARD, Constant.MAX_Bomb2s_HARD, 
            			Constant.MAX_FairyWaters_HARD, Constant.MAX_Enhancers_HARD, 
            			Constant.MAX_Poisons_HARD, Constant.MAX_Lifes_HARD);
        	}
        	Display.getDisplay(sm).setCurrent(mg);
        	
        }
	}

	public List getDiff() {
		return diff;
	}

	public void setDiff(List diff) {
		this.diff = diff;
	}
	
	
	
}
